<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
 <include file="Public/breadcrumb"/>
 <style>#search-form > .form-group{margin-left: 10px;}</style>
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i> 商品列表</h3>
        </div>
        <div class="panel-body">
          <div class="navbar navbar-default">
              <form action="{:U('Admin/goods/export_goods')}" id="search-form2" class="navbar-form form-inline" method="post" >
                <!--<div class="form-group">
                  <select name="cat_id" id="cat_id" class="form-control">
                    <option value="">所有分类</option>
                    <foreach name="categoryList" item="v" key="k" >
                        <option value="{$v['id']}"> {$v['name']}</option>
			 		</foreach>
                  </select>
                </div>
                <div class="form-group">
                  <select name="brand_id" id="brand_id" class="form-control">
                    <option value="">所有品牌</option>
                        <foreach name="brandList" item="v" key="k" >
                           <option value="{$v['id']}">{$v['name']}</option>
						</foreach>
                  </select>
                </div>                

                <div class="form-group">
                  <select name="is_on_sale" id="is_on_sale" class="form-control">
                    <option value="">全部</option>                  
                    <option value="1">上架</option>
                    <option value="0">下架</option>
                  </select>
                </div>                
                <div class="form-group">
                    <select name="intro" class="form-control">
                        <option value="0">全部</option>
                        <option value="is_new">新品</option>
                        <option value="is_recommend">推荐</option>
                    </select>                
                </div>   -->



                  <div class="form-group">
                      <select name="goods_type" id="goods_type" class="form-control">
                          <option value="">选择店铺类别</option>
                          <option value="3">天猫</option>
                          <option value="4">淘宝</option>
                          <option value="5">京东</option>
                          <option value="6">其他</option>
                      </select>
                  </div>
                  <div class="form-group">
                      <select name="status" id="is_on_sale" class="form-control">
                          <option value="">选择状态</option>
                          <option value="1">上架</option>
                          <option value="0">下架</option>
                          <option value="3">完成</option>
                      </select>
                  </div>
                  <div class="form-group">
                      <label class="control-label" for="input-date-added">添加日期</label>
                      <div class="input-group">
                          <input type="text" name="timegap" value="{$timegap}" placeholder="添加日期"  id="add_time" class="input-sm">
                      </div>
                  </div>
                  <div class="form-group">
                      <label class="control-label" for="input-order-id">关键词</label>
                      <div class="input-group">
                        <input type="text" name="key_word" value="" style="width:250px;" placeholder="输入店铺名或店铺编号搜索" id="input-order-id" class="form-control">
                      </div>
                  </div>
                <!--  <div class="form-group">
                      <label class="control-label" for="input-order-id">店铺编号</label>
                      <div class="input-group">
                          <input type="text" name="goods_number" value="" placeholder="输入店铺编号搜索" id="goods_number" class="form-control">
                      </div>
                  </div>-->
                  <!--排序规则-->
                <input type="hidden" name="orderby1" value="goods_id" />
                <input type="hidden" name="orderby2" value="desc" />
                <button type="button"  target="_blank" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</button>
                <button type="submit"    class="btn btn-default "><i class="fa fa-file-excel-o"></i> 导出excel</button>
                <button type="button" onclick="location.href='{:U('Admin/goods/addEditGoods')}'" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加新商品</button>
              </form>
          </div>
          <style>
		  .tcolor {color:#3c8dbc; font-size:14px; font-weight:bold;}
		  </style>
          <div class="table-responsive">
            <table class="table table-bordered table-hover" style="text-align:center;">
              <tr>
                <td><div class="tcolor">店铺类型</div></td>
                <td><div class="tcolor">总数</div></td>
                <td><div class="tcolor">在售</div></td>
                <td><div class="tcolor">待上架</div></td>
                <td><div class="tcolor">完成</div></td>
              </tr>
              <tr>
                <td>天猫</td>
                <td>{$count_arr.tm.sum}</td>
                <td>{$count_arr.tm.zs}</td>
                <td>{$count_arr.tm.ds}</td>
                <td>{$count_arr.tm.wc}</td>
              </tr>
              <tr>
                <td>淘宝</td>
                <td>{$count_arr.tb.sum}</td>
                <td>{$count_arr.tb.zs}</td>
                <td>{$count_arr.tb.ds}</td>
                <td>{$count_arr.tb.wc}</td>
              </tr>
              <tr>
                <td>京东</td>
                <td>{$count_arr.jd.sum}</td>
                <td>{$count_arr.jd.zs}</td>
                <td>{$count_arr.jd.ds}</td>
                <td>{$count_arr.jd.wc}</td>
              </tr>
              <tr>
                <td>其他</td>
                <td>{$count_arr.qt.sum}</td>
                <td>{$count_arr.qt.zs}</td>
                <td>{$count_arr.qt.ds}</td>
                <td>{$count_arr.qt.wc}</td>
              </tr>
              <tr>
                <td>总数量</td>
                <td colspan="5">{$count_arr.sum}</td>
              </tr>
            </table>
          </div>
          
          <!--<div class="navbar navbar-default">
                    <div >
                        <div >
                            <span>总数量：{$count_arr.sum}</span><br/>
                            <span>天猫：（总数：{$count_arr.tm.sum}&nbsp;&nbsp;&nbsp;在售：{$count_arr.tm.zs}&nbsp;&nbsp;&nbsp;待上架：{$count_arr.tm.ds}&nbsp;&nbsp;&nbsp;完成：{$count_arr.tm.wc}）</span><br/>
                            <span>淘宝：（总数：{$count_arr.tb.sum}&nbsp;&nbsp;&nbsp;在售：{$count_arr.tb.zs}&nbsp;&nbsp;&nbsp;待上架：{$count_arr.tb.ds}&nbsp;&nbsp;&nbsp;完成：{$count_arr.tb.wc}）</span><br/>
                            <span>京东：（总数：{$count_arr.jd.sum}&nbsp;&nbsp;&nbsp;在售：{$count_arr.jd.zs}&nbsp;&nbsp;&nbsp;待上架：{$count_arr.jd.ds}&nbsp;&nbsp;&nbsp;完成：{$count_arr.jd.wc}）</span><br/>
                            <span>其他：（总数：{$count_arr.qt.sum}&nbsp;&nbsp;&nbsp;在售：{$count_arr.qt.zs}&nbsp;&nbsp;&nbsp;待上架：{$count_arr.qt.ds}&nbsp;&nbsp;&nbsp;完成：{$count_arr.qt.wc}）</span>


                        </div>
                    </div>

            </div>-->
          <div id="ajax_return"> </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
<script>
    $(document).ready(function(){
		// ajax 加载商品列表
        ajax_get_table('search-form2',1);
        $('#add_time').daterangepicker({
            format:"YYYY/MM/DD",
            singleDatePicker: false,
            showDropdowns: true,
            minDate:'2016/01/01',
            maxDate:'2030/01/01',
            startDate:'2016/01/01',
            locale : {
                applyLabel : '确定',
                cancelLabel : '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1
            }
        });

    });


    // ajax 抓取页面 form 为表单id  page 为当前第几页
    function ajax_get_table(form,page){
		cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type : "POST",
                url:"/index.php?m=Admin&c=goods&a=ajaxGoodsList&p="+page,//+tab,
                data : $('#'+form).serialize(),// 你的formid
                success: function(data){
                    $("#ajax_return").html('');
                    $("#ajax_return").append(data);
                }
            });
        }
      
        // 点击排序
        function sort(field)
        {
           $("input[name='orderby1']").val(field);
           var v = $("input[name='orderby2']").val() == 'desc' ? 'asc' : 'desc';             
           $("input[name='orderby2']").val(v);
           ajax_get_table('search-form2',cur_page);
        }
        
        // 删除操作
        function del(id)
        {
            if(!confirm('确定要删除吗?'))
                return false;
		$.ajax({
			url:"/index.php?m=Admin&c=goods&a=delGoods&id="+id,
			success: function(v){	
                                var v =  eval('('+v+')');                                 
                                if(v.hasOwnProperty('status') && (v.status == 1))
                                        ajax_get_table('search-form2',cur_page);                                                      
                                else
                                        layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
			}
		}); 
               return false;
          }
</script> 
</body>
</html>